<?php
	include_once("./global.php");
	if(!$_SESSION[id]){
		if($_POST['login_sub']){
			if($_POST['login_name'] && $_POST['login_pwd']){
				$login_pwd = $_POST['login_pwd'];
				$login_name = $_POST['login_name'];
				$sql_uid = "select U_UID from userinfo where U_Loginid = '$login_name'";
				$query_uid = $mysqli->query($sql_uid);
				$result_uid = $query_uid->fetch_assoc();
				if($result_uid){
					$login_UID = $result_uid['U_UID'];
					$sql_pwd = "select U_Password from userinfo where U_UID = '$login_UID' and U_Roleid = '1'";
					$query_pwd = $mysqli->query($sql_pwd);
					$result_pwd = $query_pwd->fetch_assoc();
					if($result_pwd){
						$login_pwd = md5($_POST['login_pwd']."game818");
						if($login_pwd == $result_pwd['U_Password']){
							session_start();
							$_SESSION[id] = md5($login_name.$result_uid['U_UID'].$login_pwd.'game818');
							$tips = "登录成功";
							echo "<meta http-equiv=\"refresh\" content=\"2; url='admin_main.php'\" />";
						}else{
							$tips = "密码错误";
							echo "<meta http-equiv=\"refresh\" content=\"2; url='index.php'\" />";
						}
					}else{
						$tips = "数据库错误";
						echo "<meta http-equiv=\"refresh\" content=\"2; url='index.php'\" />";
					}
				}else{
					$tips = "用户名错误";
					echo "<meta http-equiv=\"refresh\" content=\"2; url='index.php'\" />";
				}
			}else{
				$tips = "请输入用户名密码";
				echo "<meta http-equiv=\"refresh\" content=\"2; url='index.php'\" />";
			}
		}else{
			$tips = "请重新登录";
			echo "<meta http-equiv=\"refresh\" content=\"2; url='index.php'\" />";
			
		}
	}
	

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台首页</title>
</head>
<body>
<table>
	<?php echo $tips; ?>
</table>
</body>
</html>